package org.budo.netty.servlet.util;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lmw
 */
public class ResponseUtil {
    public static void write(HttpServletResponse response, String value) {
        write(response, new ByteArrayInputStream(value.getBytes()));
    }

    public static void write(HttpServletResponse response, InputStream inputStream) {
        try {
            ServletOutputStream outputStream = response.getOutputStream();

            StreamUtil.write(inputStream, outputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}